package com.lesson12.dynamic.ex;

import java.lang.reflect.Proxy;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/10/2 13:27
 */
public class Test
{
    public static void main(String[] args)
    {
        RealStar realStar = new RealStar();
        StarHandler handler = new StarHandler(realStar);
        //代理类
        Star proxy = (Star) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[]{Star.class}, handler);
        proxy.sing();//调用代理类的唱歌方法：其实调用的是真实角色的唱歌方法
    }
}
